@echo off&setlocal enabledelayedexpansion
echo.>abc.gradle
set versionCode=0
for /f "tokens=1,2,* delims= " %%a in ('type E:\AndroidStudioProjects\AQ\app\build.gradle^|find /i "versionCode"') do (set versionCode=%%b)
set versionName=0
for /f "tokens=1,2,* delims= " %%a in ('type E:\AndroidStudioProjects\AQ\app\build.gradle^|find /i "versionName"') do (set versionName=%%b)
echo             OldVersionCode:!versionCode!
echo             oldVersionName:!versionName!
set /a newVersionCode=versionCode+1
set /a tsum=!newVersionCode!/100
set /a hsum=(!newVersionCode!-!tsum!*100)/10
set /a sum=!newVersionCode!-!tsum!*100-!hsum!*10
set /a tsum+=1
set newVersionName="!tsum!.!hsum!.!sum!"
echo {"verCode":!newVersionCode!,"verName":!newVersionName!,"forceupdate":"false","updateInfo":"What"} >apk_version.json
echo             NewVersionCode:!newVersionCode!
echo             NewVersionName:!newVersionName!
for /f "delims=" %%a in ('type E:\AndroidStudioProjects\AQ\app\build.gradle') do (
 set str=%%a
 if "%%a"=="        versionName !versionName!" (
        echo !str:%versionName%=%newVersionName%!>>E:\AndroidStudioProjects\AQ\app\abc.gradle
                                      )  else  (if "%%a"=="        versionCode !versionCode!" (
                                                     echo !str:%versionCode%=%newVersionCode%!>>E:\AndroidStudioProjects\AQ\app\abc.gradle
                           )  else  (echo %%a>>E:\AndroidStudioProjects\AQ\app\abc.gradle))

)
del E:\AndroidStudioProjects\AQ\app\build.gradle
ren E:\AndroidStudioProjects\AQ\app\abc.gradle build.gradle
call gradlew assemble
copy /b app\build\outputs\apk\app-debug.apk app\build\outputs\apk\AQ.apk
pscp -pw Starx19800724 app\build\outputs\apk\AQ.apk  apk_version.json root@www.starxnet.com:/var/www/AQ/Download
rem:warning
rem echo The tool replaceChar requires 3 command line arguments:
rem echo 1) ext name of file in which you want to replace some characters
rem echo 2) characters you want to be replaced
rem echo 3) new characters with which you want to replace some characeters
rem :end



 rem echo !vercode!